local Vector3 = GLOBAL.Vector3

local params = {}
params.chest_yamche_green_3 = {
	widget = {
		slotpos = {},
		animbank = "ui_chest_3x3",
		animbuild = "musha_chest_ui_0",
		pos = Vector3(0, 150, 0),
		side_align_tip = 160
	},
	type = "chest"
}
table.insert(params.chest_yamche_green_3.widget.slotpos, Vector3(144, 0))

params.musha_chest_2 = {
	widget = {
		slotpos = {},
		animbank = "ui_chest_3x3",
		animbuild = "musha_chest_ui_0",
		pos = Vector3(0, 200, 0),
		side_align_tip = 160
	},
	type = "chest"
}

for y = 2, 0, -1 do
	for x = 0, 2 do
		table.insert(params.musha_chest_2.widget.slotpos, Vector3(80 * x - 80 * 2 + 80, 80 * y - 80 * 2 + 80, 0))
	end
end

params.musha_chest_3 = {
	widget = {
		slotpos = {},
		animbank = "ui_chest_3x3",
		animbuild = "musha_chest_ui_1",
		pos = Vector3(0, 150, 0),
		side_align_tip = 160
	},
	type = "chest"
}

for y = 3, 0, -1 do
	for x = 0, 3 do
		table.insert(params.musha_chest_3.widget.slotpos, Vector3(60 * x - 60 * 2 + 30, 60 * y - 60 * 2 + 30, 0))
	end
end

params.musha_chest_4 = {
	widget = {
		slotpos = {},
		animbank = "ui_chest_3x3",
		animbuild = "musha_chest_ui_3",
		pos = Vector3(0, 180, 0),
		side_align_tip = 160
	},
	type = "chest"
}
for y = 5, 0, -1 do
	for x = 0, 8 do
		table.insert(params.musha_chest_4.widget.slotpos, Vector3(60 * x - 60 * 2 + -150, 60 * y - 60 * 2 + 10, 0))
	end
end

local containers = require("containers")

for k, v in pairs(params) do
	containers.MAXITEMSLOTS = math.max(containers.MAXITEMSLOTS, v.widget.slotpos ~= nil and #v.widget.slotpos or 0)
end

local oldwidgetsetup = containers.widgetsetup

function containers.widgetsetup(container, prefab, data, ...)
	local pref = prefab or container.inst.prefab
	local t = params[pref]
	if t ~= nil then
		for k, v in pairs(t) do
			container[k] = v
		end
		container:SetNumSlots(container.widget.slotpos ~= nil and #container.widget.slotpos or 0)
	else
		return oldwidgetsetup(container, prefab, data, ...)
	end
end
